// \lkj20180323
var canGetCookie = 1;
var ajaxmockjax = 1;

var CodeVal = 0;

$(document).keypress(function (e) {
    if (e.which == 13) {
        $('input[type="button"]').click();
    }
});

$('body').particleground({
    dotColor: 'rgba(255,255,255,0.8)',//'#E8DFE8',
    lineColor: 'rgba(0,0,0,0.51)' ,//'rgba(0,0,0,0)',
    curvedLines:true,
    parallaxMultiplier:5,
    parallax:true,
    particleRadius:4,
    lineWidth:0.5

   // density:10,// 粒子个数
});
$('input[name="pwd"]').focus(function () {
    $(this).attr('type', 'password');
});
$('input[type="text"]').focus(function () {
    $(this).prev().animate({ 'opacity': '1' }, 200);
});
$('input[type="text"],input[type="password"]').blur(function () {
    $(this).prev().animate({ 'opacity': '.5' }, 200);
});
$('input[name="user_name"],input[name="pwd"]').keyup(function () {
    var Len = $(this).val().length;
    if (!$(this).val() == '' && Len >= 5) {
        $(this).next().animate({
            'opacity': '1',
            'right': '30'
        }, 200);
    } else {
        $(this).next().animate({
            'opacity': '0',
            'right': '20'
        }, 200);
    }
});
var open = 0;
layui.use('layer', function () {

    $('input[type="button"]').click(function () {
        var login = $('.username').val();
        var pwd = $('.passwordNumder').val();
        if (login == '') {
            ErroAlert('请输入账号');
            return false;
        } else if (pwd == '') {
            ErroAlert('请输入密码');
            return false;
        } else {
            fullscreen();
            $('.login').addClass('test'); //添加样式
            setTimeout(function () {
                $('.login').addClass('testtwo'); //延时
            }, 300);
            setTimeout(function () {
                $('.authent').show().animate({ right: -320 }, {
                    easing: 'easeOutQuint',
                    duration: 600,
                    queue: false
                });
                $('.authent').animate({ opacity: 1 }, {
                    duration: 200,
                    queue: false
                }).addClass('visible');
            }, 500);

            //发送数据
            var JsonData = { user_name: login, pwd: pwd };
            //访问路径
            var url = "/login";

            AjaxPost(url, JsonData,
                function () {
                },
                function (data) {
                    setTimeout(function () {
                        $('.authent').show().animate({ right: 90 }, {
                            easing: 'easeOutQuint',
                            duration: 600,
                            queue: false
                        });
                        $('.authent').animate({ opacity: 0 }, {
                            duration: 200,
                            queue: false
                        }).addClass('visible');
                        $('.login').removeClass('testtwo'); //骞崇Щ鐗规晥
                    }, 2000);
                    setTimeout(function () {
                        $('.authent').hide();
                        $('.login').removeClass('test');
                        if (data.status == true) {
                            top.location.href =  data.url
                        } else {
                            ErroAlert(data.msg);
                        }
                    }, 2400);
                })

        }
        return false;
    })
})
var fullscreen = function () {
    elem = document.body;
    if (elem.webkitRequestFullScreen) {
        elem.webkitRequestFullScreen();
    } else if (elem.mozRequestFullScreen) {
        elem.mozRequestFullScreen();
    } else if (elem.requestFullScreen) {
        elem.requestFullscreen();
    } else {

    }
}
if(ajaxmockjax == 1){
    $.mockjax({
        url: 'Ajax/Login',
        status: 200,
        responseTime: 50,
        responseText: {"Status":"ok","Text":""}
    });
    $.mockjax({
        url: 'Ajax/LoginFalse',
        status: 200,
        responseTime: 50,
        responseText: {"Status":"Erro","Erro":""}
    });
}